/**
 * @file   Property.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2014-04-27
 * @brief  DON property object.
 *
 * Copyright 2014  Djuro Drljaca (djurodrljaca@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DON_CORE_PROPERTY_H
#define DON_CORE_PROPERTY_H

#include <DON/Core/DataType/AbstractDataType.h>
#include <DON/Core/Node/AccessModifier.h>
#include <DON/Core/Packet/AbstractPacket.h>
#include <QtCore/QString>

namespace DON
{
namespace Core
{
namespace Node
{

/**
 * @brief The Property class
 */
class LIBDONQT4CORESHARED_EXPORT Property
{
public:
    /**
     * @brief Constructor
     */
    Property();

    /**
     * @brief Constructor
     * @param propertyId Property ID
     * @param accessModifier Access modifier
     * @param name Property name
     * @param value Property value
     */
    Property(const quint16 propertyId,
             const AccessModifier accessModifier = AccessModifier_Invalid,
             const QString &name = QString(),
             const DataType::AbstractDataType *value = NULL);

    /**
     * @brief Copy constructor
     * @param other Object to be copied
     */
    Property(const Property &other);

    /**
     * @brief Assignment operator
     * @param other Object to be copied
     * @return This object
     */
    Property & operator=(const Property &other);

    /**
     * @brief Destructor
     */
    ~Property();

    /**
     * @brief Checks if this property is valid
     * @retval true This property is valid
     * @retval false This property is not valid
     */
    bool isValid() const;

    /**
     * @brief Get property ID
     * @return Property ID
     */
    quint16 getId() const;

    /**
     * @brief Set property ID
     * @param propertyId New property ID
     */
    void setId(const quint16 propertyId);

    /**
     * @brief Get data type
     * @return Property's data type
     *
     * @note The data type is tied to the "value" object. To change the data type you must change
     *       the value with the new data type.
     */
    DataType::DataType getDataType() const;

    /**
     * @brief Get access modifier
     * @return Access modifier
     */
    AccessModifier getAccessModifier() const;

    /**
     * @brief Set access modifier
     * @param accessModifier New access modifier
     * @retval true Success
     * @retval false Error
     */
    bool setAccessModifier(const AccessModifier accessModifier);

    /**
     * @brief Get name
     * @return Property's name
     */
    QString getName() const;

    /**
     * @brief Set name
     * @param name Property's new name
     */
    void setName(const QString &name);

    /**
     * @brief Get value
     * @return Property's value
     */
    const DataType::AbstractDataType * getValue() const;

    /**
     * @brief Set communication mode
     * @param communicationMode
     */
    void setValue(const DataType::AbstractDataType * value);

private:
    class Private;
    Private *d;
};

}
}
}

#endif // DON_CORE_PROPERTY_H
